#include "process.h"
#include <string.h>
#include <unistd.h>

#define LENGTH 101
#define LABLE '#'

void Process2(double size, double current_total) {
    static const char *sym = "|/-\\";
    static int cnt = 0;
    int sym_len = strlen(sym);

    char bar[LENGTH];
    memset(bar, '\0', sizeof(bar));
    int len = (int)current_total/size*(LENGTH-1);
    for (int i = 0; i < len; i++)
        bar[i] = '#';

    printf("[%-100s][%.1f%%][%c]\r", bar, current_total/size*(LENGTH-1), sym[cnt++]);
    fflush(stdout);
    cnt %= sym_len;
    if (size <= current_total)
        printf("\n");
}
void Process() {

    const char *symb = "|/-\\";
    int s_len = strlen(symb);
    char bar[LENGTH];
    memset(bar, '\0', sizeof(bar));
    int cnt = 0;
    while (cnt <= 100) {
        printf("[%-100s][%d%%][%c]\r", bar, cnt, symb[cnt%s_len]);
        fflush(stdout);
        bar[cnt++] = '#';
        usleep(50000);
    }
    printf("\n");
    
}

